package com.neu.neumall.order.controller;

import com.neu.neumall.order.entity.OrderEntity;
import com.neu.neumall.order.entity.OrderReturnReasonEntity;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.UUID;

/**
 * @author Hannibal
 * 2022/7/16
 * 11:56
 */
@RestController
public class RabbitController {

    @Autowired
    RabbitTemplate template;


//    @GetMapping("/sendMq")
//    public String sendMq(@RequestParam(value = "num",defaultValue = "10") Integer num){
//        for (int i=0;i<10;i++){
//            if (i%2==0){
//                OrderReturnReasonEntity reasonEntity = new OrderReturnReasonEntity();
//                reasonEntity.setId(1L);
//                reasonEntity.setCreateTime(new Date());
//                reasonEntity.setName("哈哈-"+i);
//                template.convertAndSend("hello-java-exchange","hello.java",reasonEntity,new CorrelationData(UUID.randomUUID().toString()));
//            } else {
//                OrderEntity orderEntity = new OrderEntity();
//                orderEntity.setOrderSn(UUID.randomUUID().toString());
//                template.convertAndSend("hello-java-exchange","hello22.java",orderEntity,new CorrelationData(UUID.randomUUID().toString()));
//            }
//        }
//
//        return "ok";
//    }
}
